package indi.gao.file.oss;

import com.alibaba.fastjson.JSONObject;
import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClient;
import com.aliyun.oss.model.PutObjectResult;
import org.apache.commons.io.FileUtils;

import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;

/**
 * @author :gaolei
 * @version :v1.0
 * @projectName :shop-mall-wechat
 * @description :
 * @createDate :2021/10/26 4:41 下午
 */
public class UploadFileByNameUtil {
    private static String endpoint = "http://oss-cn-beijing..com";
    private static String accessKeyId = "";
    private static String accessKeySecret = "";
    private static String bucketName = "";

    public static String formUpload(byte[] ioStream, String fileName) {
        try {
            try {
                OSS ossClient = new OSSClient(endpoint, accessKeyId, accessKeySecret);
                String objectName = "supplychain/22city/" + fileName;
                PutObjectResult result = ossClient.putObject(bucketName, objectName, new ByteArrayInputStream(ioStream));
                ossClient.shutdown();
                if (result != null) {
                    return objectName;
                }
            } catch (Exception var9) {
            }

            return null;
        } finally {
            ;
        }
    }

    public static void main(String[] args) {
//        File file = new File("/Users/gaolei/file/personalCode/GLUnitTest/FileTest/src/main/resources/saomadiancanerma.html");
//        byte[] bytes = new byte[0];
//        try {
//            bytes = FileUtils.readFileToByteArray(file);
//        } catch (IOException e) {
//            e.printStackTrace();
//        }
//        String fileName = file.getName();
//        String appID = "wx93fdd9f36d4bd22b";
//        String business = "hospitalBedLogin";
//        fileName = appID +"/"+ business + "/" + fileName;
////        InputStream inputStream = new ByteArrayInputStream(bytes);
//        String result = UploadFileByNameUtil.formUpload(bytes, "groupmeal/loginorder/saom1.html");
//        System.out.println(JSONObject.toJSONString(result));

        int oemID = 5726;
        System.out.println(7526%64);
    }
}
